#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar* menubar = new QMenuBar();
    this->setMenuBar(menubar);

    QMenu* menu1 = new QMenu("Document");
    QMenu* menu2 = new QMenu("Edit");
    QMenu* menu3 = new QMenu("Regarding");
    QMenu* menu4 = new QMenu("Build");
    QMenu* menu5 = new QMenu("Analyze");

    menubar->addMenu(menu1);
    menubar->addMenu(menu2);
    menubar->addMenu(menu3);
    menubar->addMenu(menu4);
    menubar->addMenu(menu5);

    QAction* action1 = new QAction("create new document");
    QAction* action2 = new QAction("open document");
    QAction* action3 = new QAction("exit");
    QAction* action4 = new QAction("del");
    QAction* action5 = new QAction("close");

    QList<QAction*>actionList{action1,action2,action3,action4,action5};
    menu1->addActions(actionList);

    connect(action1,&QAction::triggered,this,&MainWindow::handle);
    connect(action3,&QAction::triggered,this,&MainWindow::close);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handle()
{
   qDebug("create a new document");
}

